package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.*;
import com.hangxiang.approval.service.SecondMenuService;
import com.hangxiang.approval.vo.SecondMenuVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SecondMenu)表控制层
 *
 * @author makejava
 * @since 2020-11-25 20:04:12
 */
@RestController
@RequestMapping("secondMenu")
@Api(tags = "二级菜单相关功能")
public class SecondMenuController {
    /**
     * 服务对象
     */
    @Resource
    private SecondMenuService secondMenuService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectAllSecondMenu")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectAllSecondMenu(@RequestBody @Validated SecondMenuCommon common) {
        List<SecondMenuVo> secondMenuVoList=secondMenuService.selectAllSecondMenu(common);
        return ResultBean.success();
    }

    /**
     * 新增数据
     *
     * @param secondMenuInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertSecondMenu")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertSecondMenu(@RequestBody @Validated SecondMenuInsertCommon secondMenuInsertCommon) {
        return ResultBean.success(secondMenuService.insertSecondMenu(secondMenuInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param secondMenuUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateSecondMenu")
    @ApiOperation(value = "修改数据")
    @ResponseBody
    public ResultBean updateSecondMenu(@RequestBody @Validated SecondMenuUpdateCommon secondMenuUpdateCommon) {
        return ResultBean.success(secondMenuService.updateSecondMenu(secondMenuUpdateCommon));
    }


}